//
//  LGPatientTableViewCell.m
//  BreathTrainingTool
//
//  Created by 1234 on 2024/6/6.
//

#import "LGPatientTableViewCell.h"

@interface LGPatientTableViewCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIImageView *headPic;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *ageLabel;
/**  科室 */
@property (nonatomic , strong)UILabel *keshiLabel;
/**  病房 */
@property (nonatomic , strong)UILabel *roomTitle;
@property (nonatomic , strong)UILabel *roomLabel;
/**  床号 */
@property (nonatomic , strong)UILabel *bedTitle;
@property (nonatomic , strong)UILabel *bedLabel;

/**   */
@property (nonatomic , strong)UILabel *tuberLabel;
/**   */
@property (nonatomic , strong)UIView *percentView;
/**   */
@property (nonatomic , strong)UILabel *percentLabel;

@end

@implementation LGPatientTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.nameLabel.text = LGNSString(dataDic[@"name"]);
    NSString *sex = [LGNSString(dataDic[@"sex"]) isEqualToString:@"1"]?@"男":@"女";
    NSString *age = ([dataDic[@"age"] integerValue]>0)?[NSString stringWithFormat:@"%@岁",dataDic[@"age"]]:@"";
    self.ageLabel.text = [NSString stringWithFormat:@"%@  %@",sex,age];
    self.keshiLabel.text = LGNSString(dataDic[@"categoryName"]);
    self.roomLabel.text = LGNSString(dataDic[@"deptName"]);
    self.bedLabel.text = LGNSString(dataDic[@"bedCode"]);
    NSString *headPic = [sex isEqualToString:@"男"]?@"患者头像-男":@"患者头像-女";
    self.headPic.image = [UIImage imageNamed:headPic];
    NSString *ifTuber = LGNSString(dataDic[@"ifTuber"]);//是否结节
    self.tuberLabel.hidden = [ifTuber isEqualToString:@"1"]?NO:YES;
}

//-(void)setType:(NSString *)type{
//    _type = type;
//    BOOL inSide = [type isEqualToString:@"inside"]?YES:NO;
//    self.roomTitle.hidden = !inSide;
//    self.roomLabel.hidden = !inSide;
//    self.bedTitle.hidden = !inSide;
//    self.bedLabel.hidden = !inSide;
//    CGFloat viewH = (inSide==YES)?viewPix(120):viewPix(100);
//    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.height.equalTo(@(viewH));
//    }];
//}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    UIView *baseView = [UIView shadowViewWithColor:@"#E3E0EF" offset:CGSizeMake(0, 6) opacity:1 radius:10];
    baseView.backgroundColor = [UIColor whiteColor];
    self.baseView = baseView;
    [self.contentView addSubview:baseView];
    [baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(viewPix(5));
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.bottom.equalTo(self.contentView).offset(-viewPix(5));
        make.height.equalTo(@(viewPix(120)));
    }];
    
    self.headPic = [[UIImageView alloc]initWithFrame:CGRectMake(viewPix(16), viewPix(16), viewPix(36), viewPix(36))];
    self.headPic.cornerRidus = viewPix(18);
    [baseView addSubview:self.headPic];
    
    self.nameLabel = [UILabel lableWithText:@"" colorString:@"#2B2A37" textFont:LGFontWeight(18, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    [baseView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headPic.mas_right).offset(viewPix(12));
        make.centerY.equalTo(self.headPic);
    }];
    
    self.ageLabel = [UILabel lableWithText:@"" colorString:@"#968F8F" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    [baseView addSubview:self.ageLabel];
    
    self.tuberLabel  = [UILabel lableWithText:@"结节患者" colorString:kThemeColor textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    [self.tuberLabel addBorder:kThemeColor lineWidth:1 cornerRidus:viewPix(10)];
    [baseView addSubview:self.tuberLabel];
    
    [self.ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_right).offset(viewPix(14));
        make.centerY.equalTo(self.headPic);
        make.right.lessThanOrEqualTo(self.tuberLabel.mas_left).offset(-viewPix(10));
    }];
    [self.tuberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.lessThanOrEqualTo(baseView).offset(-viewPix(16));
        make.centerY.equalTo(self.headPic);
        make.width.equalTo(@(viewPix(60)));
        make.height.equalTo(@(viewPix(20)));
    }];
    
    UILabel *keshiTitle = [UILabel lableWithText:@"科室:" colorString:@"#968F8F" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    keshiTitle.frame = CGRectMake(viewPix(16), viewPix(65), viewPix(45), viewPix(20));
    [baseView addSubview:keshiTitle];
    
    self.keshiLabel = [UILabel lableWithText:@"" colorString:@"#2B2A37" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    [baseView addSubview:self.keshiLabel];
    [self.keshiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(keshiTitle.mas_right);
        make.centerY.equalTo(keshiTitle);
    }];
    
    UILabel *roomTitle = [UILabel lableWithText:@"病房:" colorString:@"#968F8F" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    roomTitle.frame = CGRectMake((Screen_W-viewPix(32))/2.0+viewPix(10), kMinY(keshiTitle.frame), viewPix(40), viewPix(20));
    self.roomTitle = roomTitle;
    [baseView addSubview:roomTitle];
    
    self.roomLabel = [UILabel lableWithText:@"" colorString:@"#2B2A37" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    [baseView addSubview:self.roomLabel];
    [self.roomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(roomTitle.mas_right);
        make.centerY.equalTo(roomTitle);
    }];
    
    UILabel *bedTitle = [UILabel lableWithText:@"床号:" colorString:@"#968F8F" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    bedTitle.frame = CGRectMake(viewPix(16), kMaxY(keshiTitle.frame)+viewPix(4), viewPix(40), viewPix(20));
    self.bedTitle = bedTitle;
    [baseView addSubview:bedTitle];
    
    self.bedLabel = [UILabel lableWithText:@"" colorString:@"#2B2A37" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    [baseView addSubview:self.bedLabel];
    [self.bedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bedTitle.mas_right);
        make.centerY.equalTo(bedTitle);
    }];
    
//    UIView *baseLine = [[UIView alloc]initWithFrame:CGRectMake(viewPix(16), viewPix(124), Screen_W-viewPix(193), viewPix(6))];
//    baseLine.backgroundColor = [UIColor colorWithString:@""];
//    baseLine.cornerRidus = viewPix(3);
//    [baseView addSubview:baseLine];
//
//    self.percentView  = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, viewPix(6))];
//    self.percentView.backgroundColor = [UIColor colorWithString:kThemeColor];
//    self.percentView.cornerRidus = viewPix(3);
//    [baseLine addSubview:self.percentView];
//
//    self.percentLabel = [UILabel lableWithText:@"" colorString:kThemeColor textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
//    [baseView addSubview:self.percentLabel];
//    [self.percentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(baseLine.mas_right).offset(viewPix(14));
//        make.centerY.equalTo(baseLine);
//    }];
}

@end
